<template>
  <div id="app">
    <div class="nav"  v-if="!$route.meta.hideNavbar" > 
      <!-- <router-link to="/home">首页</router-link>
      <router-link to="/rent">找房</router-link>
      <router-link to="/info">咨询</router-link>
      <router-link to="/mine">我的</router-link> -->
      <p @click="setActive(menu, index)" v-for="(menu, index) in menus" :key="index"
        :class="{ active: index == activeIndex }">{{ menu.name }}</p>
    </div>
    <router-view></router-view>
  </div>
</template>
<script>

export default {
  data() {
    return {
      activeIndex: 0,
      menus: [
        { name: '首页', path: '/home' },
        { name: '找房', path: '/rent' },
        { name: '咨询', path: '/info' },
        { name: '我的', path: '/mine' }
      ]
    }
  },
  methods: {
    setActive(menu, index) {
      if (this.$route.path !== menu.path) {
        this.activeIndex = index
        this.$router.push(menu.path)
      }
    }
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#app {
  width: 375px;
  /* margin-top: 60px; */
}

.nav {
  color: #333;
  width: 375px;
  position: fixed;
  bottom: 0;
  left: 0;
  display: flex;
  /* background-color: antiquewhite; */
  justify-content: space-between;
  align-items: center;
  height: 60px;
  padding: 0 20px;
}

.active {
  color: #6fcea2;
  /* 高亮文字颜色 */
}
</style>
